﻿namespace BPM.Web.Shared.Data;

/// <summary>
/// 组织机构树
/// </summary>
public class OrgTreeNode : ITreeNode<OrgTreeNode,long>
{
    /// <summary>
    /// Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 父Id
    /// </summary>
    public long ParentId { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string? Title { get; set; }

    /// <summary>
    /// 值
    /// </summary>
    public long Value { get; set; }

    /// <summary>
    /// 排序，越小优先级越高
    /// </summary>
    public int Weight { get; set; }

    /// <summary>
    /// 子节点
    /// </summary>
    public IEnumerable<OrgTreeNode> Children { get; set; } = Enumerable.Empty<OrgTreeNode>();

    /// <summary>
    /// 上一级Id
    /// </summary>
    public long Pid { get; set; }

    /// <summary>
    /// 有子节点
    /// </summary>
    public bool HasChildren => Children.Any();

    public long GetId() => Id;

    public long GetPid() => ParentId;
}
